using System;

namespace QuickBencher
{
    /// <summary>
    /// TODO: public API doc
    /// </summary>
    public class Printers
    {
        private static Printer _printerSetByExternal;
        private static PrinterType _usePrinterType = PrinterType.Console;

        /// <summary>
        /// TODO: public API doc
        /// </summary>
        /// <param name="type"></param>
        public static void UsePrinter(PrinterType type)
        {
            _usePrinterType = type;
        }

        /// <summary>
        /// TODO: public API doc
        /// </summary>
        /// <param name="printer"></param>
        public static void UsePrinter(Printer printer)
        {
            _printerSetByExternal = printer;
        }

        internal static Printer Get()
        {
            if (_printerSetByExternal != null)
                return _printerSetByExternal;

            switch (_usePrinterType)
            {
                case PrinterType.Console:
                    return new ConsolePrinter();
                case PrinterType.Debug:
                    return new DebugPrinter();
                case PrinterType.Trace:
                    return new TracePrinter();
                case PrinterType.Disabled:
                    return new DisabledPrinter();
                default:
                    return new ConsolePrinter();
            }
        }
    }
}
